<script setup lang="ts">
import { toRefs } from 'vue';
const props = defineProps({
  total: {
    type: Number,
    default: 0,
  },
  pageSize: {
    type: Number,
    default: 0,
  },
  page: {
    type: Number,
    default: 0,
  },
});

const { total, page, pageSize } = toRefs(props);

const emit = defineEmits(['size-change', 'current-change']);
const handleSizeChange = (val: number) => {
  console.log(`${val} items per page`);
  emit('size-change', val);
};
const handleCurrentChange = (val: number) => {
  console.log(`current page: ${val}`);
  emit('current-change', val);
};
</script>

<template>
  <el-pagination
    background
    layout="total, prev, pager, next"
    :total="total"
    :page="page"
    :page-size="pageSize"
    @size-change="handleSizeChange"
    @current-change="handleCurrentChange"
  />
</template>
<style lang="scss" scoped>
.el-pagination {
  justify-content: center;
  margin-top: 40px;
}
</style>
